package com.app.couponsharelife.ui.viewfactory

import android.util.SparseArray
import com.app.couponsharelife.base.LazyFragment
import com.app.couponsharelife.data.bean.TradingArea
import com.app.couponsharelife.ui.main.nativelife.fragment.LifeReferralsFragment
import com.app.couponsharelife.ui.main.nativelife.fragment.LifeSquareFragment1

/**
 *Created by xct on 2019/1/5
 *Description:
 */
class NativeLifeFragFactory {
    private val mFragments = SparseArray<LazyFragment>()
    fun createFragment(position: Int,tradingArea: TradingArea): LazyFragment {
        var fragment: LazyFragment? = mFragments.get(position)
        if (fragment == null) {
            when (position) {
                0 -> fragment = LifeReferralsFragment.newInstance(tradingArea) //推荐
                1 -> fragment = LifeSquareFragment1.newInstance(tradingArea) //热销
                2 -> fragment = LifeSquareFragment1.newInstance(tradingArea)
                3 -> fragment = LifeSquareFragment1.newInstance(tradingArea)
                4 -> fragment = LifeSquareFragment1.newInstance(tradingArea)
                5 -> fragment = LifeSquareFragment1.newInstance(tradingArea)
                6 -> fragment = LifeSquareFragment1.newInstance(tradingArea)
                7 -> fragment = LifeSquareFragment1.newInstance(tradingArea)
                8 -> fragment = LifeSquareFragment1.newInstance(tradingArea)
                9 -> fragment = LifeSquareFragment1.newInstance(tradingArea)
            }
            if (fragment != null) {
                mFragments.put(position, fragment)
            }
        }
        return fragment!!
    }
}